// src/api/schedule.js
import request from '@/utils/request';
// 获取排期列表
export function getScheduleList(params) {
    return request({
        url: '/schedule',
        method: 'get',
        params
    });
}

// 更新排期状态
export function updateScheduleStatus(id, data) {
    return request({
        url: `/schedule/${id}/status`,
        method: 'put',
        data
    });
}
/**
 * 创建排期
 * @param {Object} data - 排期数据
 */
export function createSchedule(data) {
    return request({
        url: '/schedule',
        method: 'post',
        data
    });
}

/**
 * 获取设备排期
 * @param {Number} deviceId - 设备ID
 * @param {String} startDate - 开始日期 (YYYY-MM-DD)
 * @param {String} endDate - 结束日期 (YYYY-MM-DD)
 */
export function getDeviceSchedule(deviceId, startDate, endDate) {
    return request({
        url: `/schedule/device/${deviceId}`,
        method: 'get',
        params: { startDate, endDate }
    });
}

/**
 * 获取广告排期
 * @param {Number} adId - 广告ID
 */
export function getAdvertisementSchedule(adId) {
    return request({
        url: `/schedule/advertisement/${adId}`,
        method: 'get'
    });
}

/**
 * 更新排期
 * @param {Number} id - 排期ID
 * @param {Object} data - 更新数据
 */
export function updateSchedule(id, data) {
    return request({
        url: `/schedule/${id}`,
        method: 'put',
        data
    });
}
/**
 * 检查协商是否已创建排期
 * @param {Number} negotiationId - 协商ID
 */
export function checkNegotiationHasSchedule(negotiationId) {
    return request({
        url: `/schedule/negotiation/${negotiationId}/has-schedule`,
        method: 'get'
    });
}


/**
 * 获取广告主的排期列表
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getAdvertiserSchedules(params) {
    return request({
        url: '/schedule/advertiser',
        method: 'get',
        params
    })
}

/**
 * 获取排期详情
 * @param {number} id 排期ID
 * @returns {Promise}
 */
export function getScheduleDetail(id) {
    return request({
        url: `/schedule/${id}`,
        method: 'get'
    })
}
/**
 * 取消排期
 * @param {number} id 排期ID
 * @returns {Promise}
 */
export function cancelSchedule(id) {
    return request({
        url: `/schedule/${id}/cancel`,
        method: 'post'
    })
}

